home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_c / pclc41.zip / DOS_IO.C < prev    next >
Text File  |  1993-09-11  |  2KB  |  74 lines

  1. /* dos_io.c */
  2.  
  3. #define BYTE unsigned char
  4.  
  5. #include  <stdio.h>
  6. #include  <dos.h>
  7.  
  8. static BYTE cur_row  = 0;      /* current row */
  9. static BYTE cur_col  = 0;      /* current col */
  10.  
  11. /* write character & attribute without advancing cursor */
  12.  
  13. void AttrWrite(BYTE ch, BYTE attr)
  14. {union REGS  reg;
  15.  reg.h.ah = 9;
  16.  reg.h.bh = 0;        /* current text page */
  17.  reg.h.al = ch;       /* character */
  18.  reg.h.bl = attr;
  19.  reg.x.cx = 1;
  20.  int86(0x10, ®, ®);
  21. }
  22.  
  23. /* position cursor at desired row & column */
  24.  
  25. void Position(BYTE row, BYTE col)
  26. {union REGS reg;
  27.  reg.h.ah = 2;
  28.  reg.h.bh = 0;
  29.  reg.h.dh = row;
  30.  reg.h.dl = col;
  31.  int86(0x10, ®, ®);
  32.  cur_row = row;
  33.  cur_col = col;
  34. }
  35.  
  36. /* returns the current row of the cursor */
  37.  
  38. int GetRow()
  39. {union  REGS  reg;
  40.  reg.h.ah = 3;
  41.  reg.h.bh = 0;
  42.  int86(0x10, ®, ®);
  43.  return(reg.h.dh);
  44. }
  45.  
  46. /* returns the current column of the cursor */
  47.  
  48. int GetCol()
  49. {union  REGS  reg;
  50.  reg.h.ah = 3;
  51.  reg.h.bh = 0;
  52.  int86(0x10, ®, ®);
  53.  return(reg.h.dl);
  54. }
  55.  
  56. /* scrolls area specified # rows */
  57.  
  58. void Scroll(
  59.    unsigned  urow,   /* upper row of area */
  60.    unsigned  lcol,   /* left column of area */
  61.    unsigned  lrow,   /* lower row of area */
  62.    unsigned  rcol,   /* right column of area */
  63.    int nrows,        /* # rows to scroll */
  64.    int attr)         /* attribute to use for blank lines */
  65. {union REGS reg;
  66.  reg.h.ah = 6;
  67.  reg.h.ch = urow;
  68.  reg.h.cl = lcol;
  69.  reg.h.al = nrows;
  70.  reg.h.bh = attr;
  71.  reg.h.dh = lrow;
  72.  reg.h.dl = rcol;
  73.  int86(0x10, ®, ®);
  74. }